package com.concerneyes.mine.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.concerneyes.R;

/**
 * Created by Administrator on 2017/6/21 0021.
 */

public class MySeverCentreAdapter extends BaseAdapter {
    private String[] listName;
    private Context context;


    public MySeverCentreAdapter(Context context) {
        this.context = context;
        listName = context.getResources().getStringArray(R.array.mine_sever_center_item_title);
    }

    @Override
    public int getCount() {
        return 7;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        switch (position) {
            case 3:
                convertView = LayoutInflater.from(context).inflate(R.layout.divider, null,false);
                convertView.setMinimumHeight(30);
                break;
            default:
                ViewHolder holder;
                if (convertView == null) {
                    holder = new ViewHolder();
                    convertView = LayoutInflater.from(context).inflate(R.layout.item_server_center, null);
                    holder.tvName = (TextView) convertView.findViewById(R.id.tv_me_title);
                    holder.tvPhone = (TextView) convertView.findViewById(R.id.tv_phone);
                    convertView.setTag(holder);
                } else {
                    holder = (ViewHolder) convertView.getTag();
                }
                holder.tvName.setText(listName[position]);
                if (position == listName.length-1){
                    holder.tvPhone.setVisibility(View.VISIBLE);
                    holder.tvPhone.setText("400-888888888");
                }
        }
        return convertView;
    }

    class ViewHolder {
        TextView tvName;
        TextView tvPhone;
    }
}
